package org.srishti.mobile;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class SignupActivity extends Activity {
  private CommentsDataSource datasource;
  long insertId;
  StringBuilder builder = new StringBuilder();
  public final static String EXTRA_MESSAGE = null;
 
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_signup);

    datasource = new CommentsDataSource(this);
    datasource.open();

  }
  // Will be called via the onClick attribute
  // of the buttons in main.xml
  public void onClick(View view) {
     
	  	String Comment = null;
	    EditText editText=(EditText) findViewById(R.id.edit_transfer);
		String message=editText.getText().toString();
		EditText editText1=(EditText) findViewById(R.id.age);
		String message1=editText1.getText().toString();
		EditText editText2=(EditText) findViewById(R.id.number);
		String message2=editText2.getText().toString();
		
	      // Save the new comment to the database
	    insertId= datasource.createComment(message,message1,message2);
	    
	    Cursor cursor= datasource.getComment(insertId);
	      
	    while (cursor.moveToNext()) {
	    	
	    	long id = cursor.getLong(0);
	    	
	    	String name = cursor.getString(1);
	        String age = cursor.getString(2);
	        String number = cursor.getString(3);
	    	builder.append(id).append("\t " );
	    	builder.append(name).append("\t " );
	    	builder.append(age).append("\t " );
	    	builder.append(number).append("\n" );
	    }
	    
	    Comment=builder.toString();
	    Intent intent=new Intent(this,DisplayMessage.class);
	      
	      intent.putExtra(EXTRA_MESSAGE,Comment);
	      startActivity(intent);
    }
    
  
  
  @Override
  protected void onResume() {
    datasource.open();
    super.onResume();
  }

  @Override
  protected void onPause() {
    datasource.close();
    super.onPause();
  }

} 